#pragma once
#include "DCylinder.h"
#include "../DSpace.h"
#include "../DVector3.h"

namespace Skill
{
	namespace Ode
	{		
		namespace Geometries
		{
			DCylinder::DCylinder(DSpace^ space, dReal radius, dReal length)
				:DGeometry(space)
			{
				dSpaceID s = space? space->_Space() : NULL;
				_SetPointer(dCreateCylinder(s,radius,length) ,true);	
				if(_Container)
						_Container->AddSpace(this);
			}

			dReal DCylinder::Radius::get()
			{
				if(IsSpace) return Single::NaN;
				dReal r,l;
				dGeomCylinderGetParams(_Geom(),&r,&l);
				return r;
			}
			void DCylinder::Radius::set(dReal value)
			{
				if(IsSpace) return;
				dReal r,l;
				dGeomCylinderGetParams(_Geom(),&r,&l);
				r = value;
				dGeomCylinderSetParams(_Geom(),r,l);
			}

			dReal DCylinder::Length::get()
			{
				if(IsSpace) return Single::NaN;
				dReal r,l;
				dGeomCylinderGetParams(_Geom(),&r,&l);
				return l;
			}
			void DCylinder::Length::set(dReal value)
			{
				if(IsSpace) return;
				dReal r,l;
				dGeomCylinderGetParams(_Geom(),&r,&l);
				l = value;
				dGeomCylinderSetParams(_Geom(),r,l);
			}

			void DCylinder::SetParams(dReal radius, dReal length)
			{
				if(IsSpace) return;
				dGeomCylinderSetParams(_Geom(),radius,length);
			}
			void DCylinder::GetParams([OutAttribute]dReal %radius, [OutAttribute]dReal %length)
			{
				if(IsSpace)
				{
					radius = Single::NaN;
					length = Single::NaN;
					return;
				}
				dReal r,l;
				dGeomCylinderGetParams(_Geom(),&r,&l);
				radius = r;
				length = l;
			}			
		}
	}
}